import math


def divisions_count(prime_counts: list) -> int:
    # prime_counts exclude 1 and number itself
    res = 1
    for item in prime_counts:
        res *= (item + 1)
    return res


if __name__ == '__main__':
    cur_num = 28
    gap_deta = 9
    prime_dict = [2, 3]
    while True:
        # update the prime dict so that it cover all prime numbers smaller than cur_num
        i = prime_dict[-1]
        i = i - (i % 6) + 6  # the condition in while can ensure i + 1 to add into the dict
        while i < cur_num // 2 + 2:  # i - (i % 6) which is divisible by 6
            judge = i - 1
            prime_dict.append(judge)
            for prime in prime_dict:
                if prime > int(pow(cur_num, 0.5)):
                    break
                if judge % prime == 0:
                    prime_dict.remove(judge)
                    break
            judge = i + 1
            prime_dict.append(judge)
            for prime in prime_dict:
                if prime > int(pow(cur_num, 0.5)):
                    break
                if judge % prime == 0:
                    prime_dict.remove(judge)
                    break
            i += 6
        prime_count = 0
        prime_counts = []
        cur_num_t = cur_num
        for prime in prime_dict:
            if cur_num_t % prime == 0:
                prime_count = 0
                while cur_num_t % prime == 0:
                    prime_count += 1
                    cur_num_t = cur_num_t // prime
                prime_counts.append(prime_count)
        if divisions_count(prime_counts) > 500:
            print(cur_num)
            break
        else:
            cur_num += gap_deta
            gap_deta += 1
